import {client} from "./uploadOss.js";

const tool = {

    oss:{
        async upload( file , data ){

            const index = file.name.lastIndexOf('.');
            console.log(index)
            // const suffix = file.name.substring(index+1);
            // console.log(suffix)

            let fileName = 'HugeData/'+ data

            console.log(fileName);

            return await client.multipartUpload( fileName, file, {
                progress: function (p) {
                    console.log('进度',p*100 )
                    this.emitProgress(p*100)
                }.bind(this)
            });
        },
        emitProgress(p) {
            this.onProgress (p);
        },
        onProgress: null  // 默认空函数
    }
}

export default tool;